package p_103

import java.net.URI

/**
 * URI 的组成
 */
class URISpliter {
    val url = "https://www.cnblogs.com/dianyu/p/11777040.html"
    fun doSome() {
        try {
            var myUrl = URI(url)
            if (myUrl.isOpaque) {
                println("--> 是透明的")
            } else { // hierarchical
                println("scheme --> ${myUrl.scheme}")
                println("scheme specific part -->${myUrl.schemeSpecificPart}")
                myUrl = myUrl.parseServerAuthority()
                println("host is --> ${myUrl.host}")
                println("userInfo is --> ${myUrl.userInfo}")
                println("port is --> ${myUrl.port}")
                println("authority is --> ${myUrl.authority}")
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

}